package com.bitbakery.plugin.scheme;

import com.bitbakery.plugin.scheme.lang.SchemeFileType;
import com.bitbakery.plugin.scheme.navigation.SchemeClassChooser;
import com.bitbakery.plugin.scheme.navigation.SchemeSymbolChooser;
import com.intellij.navigation.ChooseByNameRegistry;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.fileTypes.FileTypeManager;
import com.intellij.openapi.options.colors.ColorSettingsPages;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

public class SchemeSupportLoader implements ApplicationComponent {
    private static final String[] FILE_EXTENSIONS = new String[]{"scm"};

    public void initComponent() {
        ApplicationManager.getApplication().runWriteAction(
                new Runnable() {
                    public void run() {
                        FileTypeManager.getInstance().registerFileType(SchemeFileType.SCHEME, FILE_EXTENSIONS);
                        ColorSettingsPages.getInstance().registerPage(new SchemeColorsPage());
                    }
                });

        // TODO - Is the right place for this guy??
        ChooseByNameRegistry.getInstance().contributeToClasses(new SchemeClassChooser());
        ChooseByNameRegistry.getInstance().contributeToSymbols(new SchemeSymbolChooser());
    }

    @NotNull
    @NonNls
    public String getComponentName() {
        return "Scheme support loader";
    }


    public void disposeComponent() {
    }
}
